package com.cmhi.base.utils;

import android.app.DevInfoManager;

import com.chinamobile.SWDevInfoManager;
import com.softmbh.kellyplatform.util.AppUtils;

public class ZWDataUtils {
    public static void updateCDN() {
        SWDevInfoManager.getInstance(BimTools.getAppContext()).getValue(DevInfoManager.CDN_TYPE, cdnType -> {//华为：HW，中兴：ZTE
            AppUtils.debugLog("ZWDataUtils updateCDN()" + "start " + cdnType);
            setCDNType(cdnType);
        });
    }
    public static void setCDNType(String cdnType) {
        AppUtils.debugLog("ZWDataUtils setCDNType()" + cdnType + "  start");
        if (cdnType.equals("HW")) {
            setZwData(DevInfoManager.EPG_ADDRESS, "http://223.110.245.22:33200/EPG");
            setZwData(DevInfoManager.CDN_ADDRESS, "http://183.207.248.71:80");
            setZwData(DevInfoManager.CDN_ADDRESS_BACK, "http://183.207.249.71:80");
        } else {
            //软终端默认调用中兴 CDN，卓望软终端鉴权默认数据为中兴 CDN
            setZwData(DevInfoManager.EPG_ADDRESS, "http://223.110.239.37:9330/EPG");
            setZwData(DevInfoManager.CDN_ADDRESS, "http://223.110.239.40:6060");
            setZwData(DevInfoManager.CDN_ADDRESS_BACK, "http://223.110.240.40:6060");
        }
        AppUtils.debugLog("ZWDataUtils setCDNType()" + cdnType + "  finish");
    }
    //写入卓望数据
    public static void setZwData(String key, String value) {
        SWDevInfoManager.getInstance(BimTools.getAppContext()).update(key, value, DevInfoManager.Default_Attribute, result -> {// 0 成功，否则失败
            AppUtils.debugLog("ZWDataUtils setZwData()" + " 保存zw数据 " + key + " : " + value + " : " + (result == 0 ? "success" : result));
        });
    }
    //读取卓望数据
    public static void getZwData(String key) {
        SWDevInfoManager.getInstance(BimTools.getAppContext()).getValue(key, value ->
                AppUtils.debugLog("ZWDataUtils getZwData()" + " 读取zw数据 " + key + " : " + value)
        );
    }
}
